import java.io.*;
import java.security.*;
        
public class PasswordTest {

    public static void main(String args[]) {
        
	if (args.length != 2) {
	    System.err.println("usage: PasswordTest password testvalue");
	    System.exit(1);
	}

	byte[] buf= new byte[args[0].length()];
	args[0].getBytes(0, args[0].length(), buf, 0);

	MessageDigest algorithm = null;
	
	try {

	    algorithm = MessageDigest.getInstance("MD5");

	}catch (NoSuchAlgorithmException e) {
	    System.out.println(e);
	}

	algorithm.reset();
	algorithm.update(buf);

	byte[] digest1 = algorithm.digest();

	//System.out.println(digest1.);
	algorithm.reset();

	buf= new byte[args[1].length()];

	args[1].getBytes(0, args[1].length(), buf, 0);
	
	algorithm.update(buf);
    
	byte[] digest2 = algorithm.digest();

	for(int j=0; j<digest1.length;j++) {
	    System.out.print(digest1[j]+" ");
	}
	System.out.println();
	for(int j=0; j<digest2.length;j++) {
	    System.out.print(digest2[j]+" ");
	}

	if(digest1.length != digest2.length) {
	    System.out.println("They do not match!");
	    System.exit(0);
	}

	System.out.println();
	/*
	for(int i=0; i<digest1.length ;i++) {

	    if(digest1[i] != digest2[i]) {
		System.out.println("They do not match!");
		System.exit(0);
	    }	
	}
	*/
	if(!algorithm.isEqual(digest1,digest2)) {
		System.out.println("They do not match!");
		System.exit(0);
	}
	System.out.println("They match!");
	
    }
}

